﻿package lobby
{
	import flash.display.DisplayObject;
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	import lobby.events.LobbyEvent;
	import lobby.exchangeddata.HashTable;
	
	/**
	 * ...
	 * @author Nguyen Hoang Giang (Tom)
	 */
	public class HistoryPanelRoulette extends HistoryPanelBase
	{
		private static const GREEN:String = "green";
		private static const BLACK:String = "black";
		private static const RED:String = "red";
		
		public override function initBoard(resultArr:Array):void
		{
			removeHistory();
			if (resultArr.length == 0)
				return;
			for (var i:int = resultArr.length - 1; i >= 0; i--)
			{
				var iconHis:MovieClip = attachIcon(resultArr[i]);
				iconHis.name = (i + 1).toString();
				if (rowInd + 1 == rowNum)
				{
					rowInd = 0;
					colInd++;
				}
				else
					rowInd++;
			}
		
		}
		
		public override function attachIcon(num:String):MovieClip
		{
			var hisIcon:MovieClip = MovieClip(new HistoryIconRo());
			var icon:MovieClip = hisIcon.mc;
			hisBoard.addChild(hisIcon);
			
			hisIcon.x = colInd * 18.5 + 9.25;
			hisIcon.y = rowInd * 18.5 + 9.25;
			//hisIcon.scaleX = hisIcon.scaleY = 0.69;
			
			hisIcon.buttonMode = true;
			icon.tf.mouseEnabled = false;
			switch (num)
			{
				// zero green
				case "0": 
					icon.gotoAndStop(HistoryPanelRoulette.GREEN);
					break;
				//black
				// 2,4,6,8,10,11,13,15,17,20,22,24,26,28,29,31,33,35
				case "2": 
				case "4": 
				case "6": 
				case "8": 
				case "10": 
				case "11": 
				case "13": 
				case "15": 
				case "17": 
				case "20": 
				case "22": 
				case "24": 
				case "26": 
				case "28": 
				case "29": 
				case "31": 
				case "33": 
				case "35": 
					icon.gotoAndStop(HistoryPanelRoulette.BLACK);
					break;
				//red 
				// 1,3,5,7,9,12,14,16,18,19,21,23,25,27,30,32,34,36
				case "1": 
				case "3": 
				case "5": 
				case "7": 
				case "9": 
				case "12": 
				case "14": 
				case "16": 
				case "18": 
				case "19": 
				case "21": 
				case "23": 
				case "25": 
				case "27": 
				case "30": 
				case "32": 
				case "34": 
				case "36": 
					icon.gotoAndStop(HistoryPanelRoulette.RED);
					break;
			} //End switch
			icon.tf.text = num;
			return hisIcon;
		}
	}

}